#import "AddressBook.h"

@implementation AddressBook;

// Ustawienie nazwy ksiki adresowej i utworzenie pustej ksiki

-(id) initWithName: (NSString *) name
{
    self = [super init];
    if (self) {
        bookName = [[NSString alloc] initWithString: name];
        book = [[NSMutableArray alloc] init];
    }

    return self;
}

-(id) init
{
    return [self initWithName: @"BezNazwy"];
}

-(void) addCard: (AddressCard *) theCard
{
    [book addObject: theCard];
}

-(int) entries
{
    return [book count];
}

-(void) list
{
    NSLog (@"======== Zawarto: %@ =========", bookName);

    for ( AddressCard *theCard in book )
        NSLog (@"%-20s    %-32s", [theCard.name UTF8String],
                     [theCard.email UTF8String]);

    NSLog (@"==================================================");
}

-(void) dealloc
{
    [bookName release];
    [book release];
    [super dealloc];
}
@end